//
//  InforTableViewCell.m
//  B_WatchHome
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 DHF. All rights reserved.
//

#import "InforTableViewCell.h"
#import <UIImageView+WebCache.h>
#import <Masonry.h>

@implementation InforTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self createSubViews];
    }
    return self;
}


- (void)createSubViews
{
    
    self.leftimageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.leftimageView];
    [self.leftimageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.mas_equalTo(10);
        make.size.mas_equalTo(CGSizeMake(120, 120));
        
    }];
    
    
    self.contentLabel = [[UILabel alloc] init];
    
    self.contentLabel.numberOfLines = 0;
    self.contentLabel.font = [UIFont boldSystemFontOfSize:18];
    [self.contentView addSubview:self.contentLabel];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.left.equalTo(self.leftimageView.mas_right).offset(20);
        
    }];
    
    self.dateLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.dateLabel];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftimageView.mas_right).offset(20);
        make.bottom.mas_equalTo(-10);
        
    }];
    
    self.brandLabel = [[UILabel alloc] init];
    self.brandLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.brandLabel];
    
    [self.brandLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.bottom.mas_equalTo(-10);
        
    }];
    










}
- (void)setModel:(InforTableModel *)model
{
    if (_model != model) {
        _model = model;
    }
    
    self.contentLabel.text = self.model.title;
    
    NSString *str = self.model.updatetime;
    
    NSArray *array = [str componentsSeparatedByString:@" "];
    
    self.dateLabel.text = [array objectAtIndex:0];
    
    self.brandLabel.text = self.model.brand_name;
    
    NSURL *url = [NSURL URLWithString:self.model.img];
    
    [self.leftimageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@""]];
    
}










- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
